package ch03.demo.service.impl;

import ch03.demo.dao.NewDao;
import ch03.demo.dao.impl.NewDaoImpl;
import ch03.demo.pojo.News;
import ch03.demo.service.NewsService;

/**
 * 新闻模块业务类
 */
public class NewsServiceImpl implements NewsService {

    //所依赖的NewDao对象
    private NewDao dao;

    public void setDao(NewDao dao) {
        this.dao = dao;
    }

    //调用数据访问层接口中的save方法
    NewDao newDao=new NewDaoImpl();

    public void addNews(News news){
        dao.save(news);
    }
    @Override
    public void save(News news) {
        //调用NewsDao接口中的save方法完成保存新闻信息操作
        newDao.save(news);
    }
}
